//
//  LDJ_SoudCell.m
//  Pianke
//
//  Created by dllo on 15/12/24.
//  Copyright © 2015年 dada. All rights reserved.
//

#import "LDJ_SoudCell.h"

@implementation LDJ_SoudCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubView];
    }
    return self;
}

-(void)createSubView{
    
    
    //类型
    self.type = [[UILabel alloc]init];
    self.type.text = @"心理.Psychology";
    self.type.font = [UIFont systemFontOfSize:12];
    self.type.textColor = [UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:1];
    [self.contentView addSubview:self.type];
    [self.type mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(150 * EACH_WIDTH, 15 * EACH_HEIGHT));
        make.left.mas_equalTo(20 * EACH_WIDTH);
        make.top.mas_equalTo(10 * EACH_HEIGHT);
        
    }];
    
    
    
    
    //图片
    self.soundImageView = [[UIImageView alloc]init];
    self.soundImageView.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.soundImageView];
    
    [self.soundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 120 * EACH_WIDTH, 140 * EACH_HEIGHT));
        make.left.equalTo(self.type.mas_left).offset(40);
        make.top.mas_equalTo(self.type.mas_bottom).offset(20 * EACH_HEIGHT);
        
    }];
    
    
    
    //标题
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.font = [UIFont systemFontOfSize:20 * EACH_HEIGHT];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.text = @"片刻平安夜Party";
    [self.titleLabel  mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.soundImageView);
        make.top.mas_equalTo(self.soundImageView.mas_bottom).offset(30 * EACH_HEIGHT);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 80 * EACH_WIDTH, 20 * EACH_HEIGHT));
        
    }];
    
    //按钮背景
    self.playImageView = [[UIImageView alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 44) / 2, 170, 44, 44)];
    self.playImageView.image = [UIImage imageNamed:@"cm2_radio_btn_play@2x.png"];
    
    [self.contentView addSubview:self.playImageView];

    
    
    //发布者
    self.author = [[UILabel alloc]init];
    self.author.font = [UIFont systemFontOfSize:EACH_HEIGHT * 13];
    self.author.textAlignment = NSTextAlignmentCenter;
    self.author.textColor = [UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:1];
    self.author.text = @"by:NJ文珂";
    [self.contentView addSubview:self.author];
    
    [self.author mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.left.equalTo(self.titleLabel);
        make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10 * EACH_HEIGHT);
    }];
    
    
    
    //心形图
    self.heartButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.heartButton  setImage:[UIImage imageNamed:@"iconfont-xinxihuan00-2.png"] forState:UIControlStateNormal];
    [self.contentView addSubview: self.heartButton];
    [self.heartButton addTarget:self action:@selector(heartButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.heartButton mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(15 * EACH_WIDTH, 15 * EACH_HEIGHT));
        make.top.mas_equalTo(self.author.mas_bottom).offset(30 * EACH_HEIGHT);
        make.right.mas_equalTo(-60);
        
        
    }];
    
    
    //赞数
    self.zanLabel = [[UILabel alloc]init];
    self.zanLabel.font = [UIFont systemFontOfSize:EACH_HEIGHT * 12];
    self.zanLabel.textColor = [UIColor colorWithRed:0.47 green:0.47 blue:0.47 alpha:1];
    self.zanLabel.text = @"311";
    [self.contentView addSubview:self.zanLabel];
    [self.zanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(50 * EACH_WIDTH, 15 * EACH_HEIGHT));
        make.left.mas_equalTo(self.heartButton.mas_right).offset(10);
        make.top.equalTo(self.heartButton);
        
    }];
    
    
}

-(void)setSoundModel:(LDJ_HomeModel *)soundModel{
    
    NSString *str = [NSString stringWithFormat:@"%@•%@",soundModel.name,soundModel.enname];
    self.type.text = str;
    self.titleLabel.text = soundModel.title;
    NSString *s = [NSString stringWithFormat:@"by：%@",[soundModel.userinfo objectForKey:@"uname"]];
    self.author.text = s;
    NSString *string = [NSString stringWithFormat:@"%@", soundModel.like];
    self.zanLabel.text = string;
    
    [self.soundImageView sd_setImageWithURL:soundModel.coverimg placeholderImage:[UIImage imageNamed:@"u=2806788904,174307870&fm=21&gp=0.jpg"]];
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
